﻿
Partial Class Register
    Inherits BasePage

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        lblError.Text = ""
        If txtPass.Text.Equals(txtPass2.Text) Then
            Dim err As String = ""
            Dim s As MembershipCreateStatus
            Dim u As MembershipUser = _
                Membership.CreateUser(txtUsername.Text, txtPass.Text, txtEmail.Text, Nothing, Nothing, SiteSettings.AutoApproveUsers, s)
            Select Case s
                Case MembershipCreateStatus.DuplicateEmail
                    err = "A username for that e-mail address already exists. Please enter a different e-mail address."
                Case MembershipCreateStatus.DuplicateUserName
                    err = "Username already exists. Please enter a different user name."
                Case MembershipCreateStatus.InvalidEmail
                    err = "The e-mail address provided is invalid. Please check the value and try again."
                Case MembershipCreateStatus.InvalidPassword
                    err = "The password provided is invalid. Please enter a valid password value."
                Case MembershipCreateStatus.InvalidUserName
                    err = "The user name provided is invalid. Please check the value and try again."
                Case MembershipCreateStatus.Success
                    Response.Redirect(Utils.RelativeWebRoot & "default.aspx")
                Case MembershipCreateStatus.UserRejected
                    err = "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator."
                Case Else
                    err = "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator."
            End Select
            lblError.Text = err
        Else
            lblError.Text = "Passwords do not match!"
        End If
    End Sub

    Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If SiteSettings.AutoApproveUsers = False Then
                lblMessage.Text = "<b>NOTE:</b> New users require an administrator to approve prior to accessing site."
            Else
                lblMessage.Text = ""
            End If
        End If
    End Sub
End Class
